<template>
  <div>
    <ul class="blogs">
      <li
        v-for="(item, index) in datas"
        :key="index"
        border="0"
        style="cursor: pointer"
      >
        <div class="imgs">
          <img :src="item.picUrl" alt="" />

          <div class="jinr">
            <img src="../../assets/bfs.png" alt="" />
          </div>
        </div>
        <div class="texts">
          <div>
            <span class="tesx">{{ item.copywriter | ellipsis }}</span>
          </div>
          <div>
            <span class="biaoq">{{ item.category }}</span>
          </div>
          <div class="txtwlog">
            <span class="nickname">{{ item.name | nic }}</span>
            <div class="rwa">
              <img src="../../assets/bfw.png" alt="" />
            </div>
            <span class="bufang">{{ item.playCount | jshu }}</span>
            <div class="rwa">
              <img src="../../assets/sj.png" alt="" />
            </div>
            <span class="bufang">{{ item.programCount | dates }}</span>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: ["blogsdata"],
  watch: {
    blogsdata(val) {
      this.datas = val;
    },
  },
  data() {
    return {
      datas: [],
    };
  },
  created() {
    // console.log(this.datas);
  },
  filters: {
    //播放量
    jshu: (value) => {
      // console.log(value);
      if (value / 100000000 > 1) {
        return parseInt(value / 100000000) + "亿";
      } else {
        return parseInt(value / 10000) + "万";
      }
    },
    ellipsis(value) {
      if (!value) return "";
      if (value.length > 20) {
        return value.slice(0, 20) + "...";
      }
      return value;
    },
    nic(value) {
      if (!value) return "";
      if (value.length > 15) {
        return value.slice(0, 8) + "...";
      }
      return value;
    },
    dates(value1) {
      let result = parseInt(value1);
      let h =
        Math.floor(result / 3600) < 10
          ? "0" + Math.floor(result / 3600)
          : Math.floor(result / 3600);
      let m =
        Math.floor((result / 60) % 60) < 10
          ? "0" + Math.floor((result / 60) % 60)
          : Math.floor((result / 60) % 60);
      let s =
        Math.floor(result % 60) < 10
          ? "0" + Math.floor(result % 60)
          : Math.floor(result % 60);
      result = `${m}:${s}`;
      return result;
    },
  },
};
</script>

<style lang="less" scoped>
.blogs {
  display: flex;
  justify-content: space-between;
  flex-flow: wrap;
  li {
    &:hover {
      background-color: rgba(213, 214, 214, 0.61);
      border-radius: 5px;
    }
    margin-bottom: 20px;
    // height: 120px;
    // border: 1px solid #000;
    flex-basis: 49%;
    display: flex;
    align-items: center;
    .imgs {
      width: 90px;
      position: relative;
      //   border: 1px solid #000;
      display: flex;
      height: 90px;
      overflow: hidden;
      align-items: center;
      img {
        width: 100%;
        height: 100%;
        border-radius: 5px;
      }
      .jinr {
        position: absolute;
        z-index: 2;
        bottom: 5px;
        right: 5px;
        width: 30px;
        height: 30px;
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
    .texts {
      margin-left: 10px;
      height: 80%;
      //   border: 1px solid #000;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .biaoq {
        // display: inline;
        color: rgb(145, 144, 144);
        border-radius: 3px;
        border: 1px solid rgb(145, 144, 144);
        padding: 2px 2px 2px 2px;
      }
      .txtwlog {
        span {
          color: rgb(145, 144, 144);
        }
        display: flex;
        .nickname {
        }
        .bufang {
          margin-left: 5px;
        }
        .rwa {
          margin-left: 10px;
          width: 15px;
          height: 15px;
          img {
            width: 100%;
            height: 100%;
          }
        }
      }
    }
  }
}
</style>